package com.kanas.webak.config.repository;

import java.util.Date;
import java.util.Iterator;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.kanas.webak.config.domain.Sequence;

public interface SequenceRepository extends CrudRepository<Sequence,String> {
	Sequence findByCode(String code);
	Iterator<Sequence> findByResetInterval(Sequence.ResetIntervalType interval);
	@Modifying
	@Query("update KanasSequence s set s.value = 0, s.lastUpdate=?1 where s.resetInterval = ?2")
	int reset(Date lastUpdate, String interval);
}
